package com.hq.fxh.No3_TuiGuang.MyMoBan.Activity.item;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hq.fxh.No3_TuiGuang.MyMoBan.Activity.AdBannerInfo;
import com.hq.fxh.R;


/**
 * @author 大圣
 * @ClassName QQAdContentItem
 * @Description :
 * @Created 16/6/24
 * @Email qwqe601660957@163.com
 */
public class QQAdContentItem extends LinearLayout {
    /** 名片广告图片 */
    private ImageView ivCardPic;
    /** 名称 */
    private TextView tvName;
    /** 手机号 */
    private TextView tvPhone;
    /** 地址 */
    private TextView tvAddress;
    //    private AppCompatCheckBox cbPic;
    public QQAdContentItem(Context context) {
        super(context);
        inflate(context, R.layout.item_qq_ad_content, this);
        initView();
    }

    private void initView() {
        ivCardPic = (ImageView) findViewById(R.id.ivCardPic);
        tvName = (TextView) findViewById(R.id.tvName);
        tvPhone = (TextView) findViewById(R.id.tvPhone);
        tvAddress = (TextView) findViewById(R.id.tvAddress);
//        cbPic = (AppCompatCheckBox) findViewById(R.id.cbPic);
    }

    /**
     *
     * @param adInfo
     */
    public void showAdInfo(final AdBannerInfo adInfo){
        if(adInfo != null){
            final AdBannerInfo.AdvertDetailBean merchantArticleQQModel = adInfo.getAdvert_detail();
            if(merchantArticleQQModel != null){
                tvName.setText(merchantArticleQQModel.getQQ());
                tvPhone.setText(merchantArticleQQModel.getMobile());
                tvAddress.setText(merchantArticleQQModel.getDes());
//                final Pic cardPic = merchantArticleQQModel.getUserPic();
//                if(cardPic != null){
//                    if(cardPic.isNative()){
//                        Bitmap bitmap = ImageUtils.bytes2Bimap(Base64.decode(cardPic.getPicData(), Base64.DEFAULT));
//                        ivCardPic.setImageBitmap(bitmap);
//                    }else{
//                        String url = cardPic.getPicUrl();
//                        if(!TextUtils.isEmpty(url)){
//                            IImageLoader.getInstance().load(getContext(),ivCardPic,url);
//                        }else{
//                            ivCardPic.setImageResource(R.drawable.icon_ad_qq_default);
//                        }

                String url = merchantArticleQQModel.getPic();
                        if(!TextUtils.isEmpty(url)){
                    //        GlideUtils.loadRoundedImage(getContext(),url,getContext().getResources().getDimensionPixelSize(R.dimen.size_6),ivCardPic);
                        }else{
                            ivCardPic.setImageResource(R.mipmap.qq);
                        }
                    }
                }
            }
        }

